package com.async.service;

import com.async.Hander.SyncExctionHandler;
import com.async.entity.Student;
import com.async.mapper.StudentMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.concurrent.ExecutionException;

@Service
@Slf4j
public class StudentService extends ServiceImpl<StudentMapper, Student> {

    @Autowired
    private SyncExctionHandler syncExctionHandler;


    /**
     * 多线程某个线程出问题回滚
     *
     * @throws ExecutionException
     * @throws InterruptedException
     */
    public void testSyncException() throws Exception {
//        List<Future<String>> list = new ArrayList<>();
//        for (int i = 0; i < 5; i++) {
//            list.add(syncExctionHandler.syncException(i));
//        }
//        for (Future<String> future : list) {
//            System.out.println(future.get());
//        }

    }


    public List<Student> studentList(Page page) {
        return baseMapper.studentList(page);
    }


}
